<?php
my_component_load('testing' , false);
my_component_load('paging' , false); 
my_component_load('data_setting', false);
my_component_load('profesi' );
$task = isset($_GET['task']) ? $_GET['task'] : ""; 

$pid = isset( $_GET['pid'] ) ? $_GET['pid']:  0;
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$modulname = "Admin _BN_ Konfigurasi Data _BN_ Profesi";

if($_SERVER['REQUEST_METHOD'] == "POST" ):
	switch($task){
		case   "profesi_page" :
			$validatepost = form_profesi_validate($id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_profesi_create($id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_profesi_submit($id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}	
			my_direct('index.php?com=profesi');
			break;
		case   "profesi_detail_page" :
			$validatepost = form_profesi_detail_validate($pid,$id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_profesi_detail_create($pid,$id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_profesi_detail_submit($pid,$id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}	
			my_direct('index.php?com=profesi&task=list_profesi_detail&pid='.$pid);
			break;			
		case   "profesi_page" :
			$validatepost = form_profesi_validate($id);
			if($validatepost){
				$content = message_multi_error($validatepost);
				$content .= form_profesi_create($pid,$id);
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_profesi_submit($pid,$id);
				$content =  "Updated";
				generate_my_web($content,"","plain.php");
				exit;
			}	
			my_direct('index.php?com=profesi&task=list_profesi&pid='.$pid);
			break;	
	}
else: 
	 
	if($task =='list_profesi_detail'){	
		$pagename = "Detail Profesi";
		load_facebox_script();
		$view =  list_profesi_detail($pid); 
		$href = 'index.php?com=profesi&task=profesi_detail_create&pid='.$pid.'&id=0';
	}elseif($task == "profesi_detail_page"){ 
		$content  = form_profesi_detail_create($pid,$id);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == "profesi_detail_create"){ 
		$title= ($id > '0' ) ?  "Perubahan Data" : "Tambah Data";
		facebox_page('index.php?com=profesi&task=profesi_detail_page&pid='.$pid.'&id='.$id , $title , 200	);
	}elseif($task =='profesi_detail_delete'){
		 delete_profesi_detail($id);
		 my_direct($_SERVER['HTTP_REFERER']);	
		 
	}elseif($task == "profesi_page"){ 
		$content  = form_profesi_create($id);
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == "profesi_create"){ 
		$title= ($id > '0' ) ?  "Perubahan Data Profesi" : "Tambah Data Profesi";
		facebox_page('index.php?com=profesi&task=profesi_page&id='.$id , $title , 200	);
	}elseif($task =='profesi_delete'){
		 delete_profesi($id);
		 my_direct($_SERVER['HTTP_REFERER']);			 
	 

	}else{
		$pagename = "Profesi";
		load_facebox_script();
		$view =  list_profesi(); 
		$href = 'index.php?com=profesi&task=profesi_create';
	}
endif; 
$content = spliter_browser( $view , $pagename ,$href);
generate_my_web($content, $modulname );

?>